<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>质量问题基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <!--<link rel="stylesheet" href="/qbdmsStatic/style/forms/currencyCss.css">-->
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
    <style>
        .layui-table th{
            background: #fbfcfe;color: #606266
        }
        .layui-table th{
            border: 1px solid #E5F0FF;
        }
    </style>
</head>
<body class="listBody">
<div class="qbdms-bodyDiv">
<div class="layui-table-view-body qbdms-add-view-body">
<form class="layui-form"  requrl="${ctx}/qbdms/wQbdFalProblemreset/getHistories" lay-filter="wQbdFalProblemresetDataForm">
    <div class="qbdms-formTitle">质量问题版本对比<i class="qbdms-returnOn closeWindow">返回</i></div>
    <div style="height: 100%;overflow-y: auto;">
        <table class="layui-table qbdms-zeroTable" style="margin: 0">
            <thead>
                <tr class="tableTitle" >
                    <th style="min-width: 148px"></th>
                </tr>
            </thead>
            <tbody>
                <tr class="tableData" dataFieldName="fProblemname">
                    <td class="qbdms-zeroTable-lable">质量问题名称</td>
                </tr>
                <tr class="tableData" dataFieldName="fDetecttime">
                    <td class="qbdms-zeroTable-lable">问题发生时间</td>
                </tr>
                <tr class="tableData" dataFieldName="fModelsymbol">
                    <td class="qbdms-zeroTable-lable">型号代号</td>
                </tr>
                <tr class="tableData" dataFieldName="fModelname">
                    <td class="qbdms-zeroTable-lable">型号名称</td>
                </tr>
                <tr class="tableData" dataFieldName="fModelbatchno">
                    <td class="qbdms-zeroTable-lable">型号批次</td>
                </tr>
                <tr class="tableData" dataFieldName="fModelname">
                    <td class="qbdms-zeroTable-lable">型号名称</td>
                </tr>
                <tr class="tableData" dataFieldName="fModeltype">
                    <td class="qbdms-zeroTable-lable">型号类别</td>
                </tr>
                <tr class="tableData" dataFieldName="fWorkphase1">
                    <td class="qbdms-zeroTable-lable">工作阶段</td>
                </tr>
                <tr class="tableData" dataFieldName="fProductname">
                    <td class="qbdms-zeroTable-lable">故障产品名称</td>
                </tr>
                <tr class="tableData" dataFieldName="filldate">
                    <td class="qbdms-zeroTable-lable">填写日期</td>
                </tr>
                <tr class="tableData" dataFieldName="fModeldevelopphase">
                    <td class="qbdms-zeroTable-lable">型号研制阶段</td>
                </tr>
                <tr class="tableData" dataFieldName="fProductbatchno">
                    <td class="qbdms-zeroTable-lable">故障产品所属的产品批次</td>
                </tr>
                <tr class="tableData" dataFieldName="fProduceclass">
                    <td class="qbdms-zeroTable-lable">生产分类</td>
                </tr>
                <tr class="tableData" dataFieldName="fBreakphase">
                    <td class="qbdms-zeroTable-lable">故障件阶段</td>
                </tr>
                <tr class="tableData" dataFieldName="fProductlevel">
                    <td class="qbdms-zeroTable-lable">产品级别</td>
                </tr>
                <tr class="tableData" dataFieldName="fProductdesigndept">
                    <td class="qbdms-zeroTable-lable">产品设计单位</td>
                </tr>
                <tr class="tableData" dataFieldName="fProductproducedept">
                    <td class="qbdms-zeroTable-lable">产品生产单位</td>
                </tr>
                <tr class="tableData" dataFieldName="fDetectplace">
                    <td class="qbdms-zeroTable-lable">问题发生地点</td>
                </tr>
                <tr class="tableData" dataFieldName="fSubsystemname">
                    <td class="qbdms-zeroTable-lable">所属分系统名称</td>
                </tr>
                <tr class="tableData" dataFieldName="fIffirstfly">
                    <td class="qbdms-zeroTable-lable">是否首飞</td>
                </tr>
                <tr class="tableData" dataFieldName="fIfshooting">
                    <td class="qbdms-zeroTable-lable">是否靶场质量问题</td>
                </tr>
                <tr class="tableData" dataFieldName="fIfbatch">
                    <td class="qbdms-zeroTable-lable">是否批次性</td>
                </tr>
                <tr class="tableData" dataFieldName="fIfthree">
                    <td class="qbdms-zeroTable-lable">是否三类问题</td>
                </tr>
                <tr class="tableData" dataFieldName="fProblemrank">
                    <td class="qbdms-zeroTable-lable">问题等级</td>
                </tr>
                <tr class="tableData" dataFieldName="fSofthard">
                    <td class="qbdms-zeroTable-lable">硬件/软件</td>
                </tr>
                <tr class="tableData" dataFieldName="fProblemlever">
                    <td class="qbdms-zeroTable-lable">问题级别</td>
                </tr>
                <tr class="tableData" dataFieldName="fResetday">
                    <td class="qbdms-zeroTable-lable">归零周期</td>
                </tr>
                <tr class="tableData" dataFieldName="fFailuredescription">
                    <td class="qbdms-zeroTable-lable">问题/故障现象描述</td>
                </tr>
                <tr class="tableData" dataFieldName="fDeepreason">
                    <td class="qbdms-zeroTable-lable">深层次原因</td>
                </tr>
                <tr class="tableData" dataFieldName="fCausation">
                    <td class="qbdms-zeroTable-lable">问题原因描述</td>
                </tr>
                <tr class="tableData" dataFieldName="fFourrefer">
                    <td class="qbdms-zeroTable-lable">“四个两”要求对照分析</td>
                </tr>
                <tr class="tableData" dataFieldName="fCausationclass1">
                    <td class="qbdms-zeroTable-lable">原因分类1</td>
                </tr>
                <tr class="tableData" dataFieldName="fCausationclass2">
                    <td class="qbdms-zeroTable-lable">原因分类2</td>
                </tr>
                <tr class="tableData" dataFieldName="fDutydept">
                    <td class="qbdms-zeroTable-lable">问题责任单位</td>
                </tr>
                <tr class="tableData" dataFieldName="fDutydeptnature">
                    <td class="qbdms-zeroTable-lable">责任单位性质</td>
                </tr>
                <tr class="tableData" dataFieldName="fIfreset">
                    <td class="qbdms-zeroTable-lable">是否完成归零</td>
                </tr>
                <tr class="tableData" dataFieldName="fResettype">
                    <td class="qbdms-zeroTable-lable">归零方式</td>
                </tr>
                <tr class="tableData" dataFieldName="fResettime">
                    <td class="qbdms-zeroTable-lable">归零时间</td>
                </tr>
                <tr class="tableData" dataFieldName="fSolveresult">
                    <td class="qbdms-zeroTable-lable">解决情况</td>
                </tr>
                <tr class="tableData" dataFieldName="fMeasureclass">
                    <td class="qbdms-zeroTable-lable">问题处理方式</td>
                </tr>
                <tr class="tableData" dataFieldName="fCorrectmeasure">
                    <td class="qbdms-zeroTable-lable">纠正措施</td>
                </tr>
                <tr class="tableData" dataFieldName="fOutdeptname">
                    <td class="qbdms-zeroTable-lable">外协外购乙方</td>
                </tr>
                <tr class="tableData" dataFieldName="fRanage">
                    <td class="qbdms-zeroTable-lable">举一反三</td>
                </tr>
                <tr class="tableData" dataFieldName="fIndusty">
                    <td class="qbdms-zeroTable-lable">行业</td>
                </tr>
                <tr class="tableData" dataFieldName="fOutnature">
                    <td class="qbdms-zeroTable-lable">外协性质</td>
                </tr>
                <tr class="tableData" dataFieldName="fSoftrank">
                    <td class="qbdms-zeroTable-lable">软件等级</td>
                </tr>
                <tr class="tableData" dataFieldName="fManagefactoranalysis">
                    <td class="qbdms-zeroTable-lable">管理因素分析</td>
                </tr>
                <tr class="tableData" dataFieldName="fSkillresettime">
                    <td class="qbdms-zeroTable-lable">技术归零时间</td>
                </tr>
                <tr class="tableData" dataFieldName="fManageresettime">
                    <td class="qbdms-zeroTable-lable">管理归零时间</td>
                </tr>
                <tr class="tableData" dataFieldName="fIfmating">
                    <td class="qbdms-zeroTable-lable">是否集团内配套</td>
                </tr>
                <tr class="tableData" dataFieldName="fSkillcerfile">
                    <td class="qbdms-zeroTable-lable">技术归零报告及文件</td>
                </tr>
                <tr class="tableData" dataFieldName="fManagecerfile">
                    <td class="qbdms-zeroTable-lable">管理归零报告及文件</td>
                </tr>
                <tr class="tableData" dataFieldName="fIfduty">
                    <td class="qbdms-zeroTable-lable">是否责任追究</td>
                </tr>
                <tr class="tableData" dataFieldName="fDutyinvestigationtyp">
                    <td class="qbdms-zeroTable-lable">责任追究类别</td>
                </tr>
                <tr class="tableData" dataFieldName="fIdentification">
                    <td class="qbdms-zeroTable-lable">认定情况</td>
                </tr>
                <tr class="tableData" dataFieldName="punishRenson">
                    <td class="qbdms-zeroTable-lable">处罚原因</td>
                </tr>
                <tr class="tableData" dataFieldName="fConfirmdutyinvest">
                    <td class="qbdms-zeroTable-lable">是否完成责任追究</td>
                </tr>
                <tr class="tableData" dataFieldName="fAllcount">
                    <td class="qbdms-zeroTable-lable">处罚总金额</td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="layui-form-item btnformItem">
        <p>
            <button type="reset" id="closeWindow"
                    class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">取消
            </button>
        </p>
    </div>
    <!--<div class="layui-form-item" style="width: 97%;margin: 0;height: 60px;line-height: 60px;">-->
        <!--<div style="text-align: center;">-->
            <!--<button type="reset" id="closeWindow" style="margin-left: 10px;" class="layui-btn btn-n layui-btn-danger btn-save">取消</button>-->
        <!--</div>-->
    <!--</div>-->
</form>
</div>
</div>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>

    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','common','laydate','jquery','publicMethods','qbdmsForm'], function () {
        var laydate = layui.laydate;
        var common = layui.common;
        var $ = layui.jquery,
        publicMethods = layui.publicMethods,
        form = layui.qbdmsForm;
        var dateTimeFiledLen = $(".dateTimeFiled");
        for(var i=0;i<dateTimeFiledLen.length;i++){
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                ,type: 'date'
                ,trigger: 'click'

            });
        }

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFalProblemreset/view/list';
        });

        var id = "${id}";
        var firstItem;
        var diffStyle = "font-weight: bold; background-color: #f1f1f1";
        //-- 转换日期数据和附件数据 开始 -------------------------------------------------------------------------
        /**
         * 按照fieldName转换日期和附件格式
         * @param fieldName
         * @param val
         * @returns {*|string}
         */
        function convertFieldType(fieldName, val) {
            var result = val;
            if (fieldName == "fDetecttime" || fieldName == "fSkillresettime" || fieldName == "fManageresettime" || fieldName == "fResettime") {
                result = publicMethods.timeData(val);
            } else if (fieldName == "fSkillcerfile" || fieldName == "fManagecerfile") {
                if (val && val != "" && val != null) {
                    var obj = eval(val);
                    result = "";
                    $.each(obj, function () {
                        result += this.fileName + ";";
                    });
                    result = result.slice(0, result.length - 1);
                }
            }
            return result;
        }
        //-- 转换日期数据和附件数据 结束 -------------------------------------------------------------------------



        var htmlDecodeByRegExp = function(str){
            var s = "";
            if(str.length == 0) return "";
            if(typeof str != "string") return str;
            try {
                s = str.replace(/&amp;/g, "&");
                s = s.replace(/&lt;/g, "<");
                s = s.replace(/&gt;/g, ">");
                s = s.replace(/&nbsp;/g, " ");
                s = s.replace(/'/g, "\'");
                s = s.replace(/"/g, "\"");
                s = s.replace(/&quot;/g, "\"");
                s = s.replace(/&apos;/g, "\'");
            }catch(err){
                console.log(str);
            }
            return s;
        };
        common.updateForm({
            name:'wQbdFalProblemresetDataForm',
            idValue:id,
            primary:"id",
            getCallback:function(data){
                // console.log(data);
                // var data = [{"title":"asdf", "fProblemname":123},{"title":["x", "y"], "fProblemname":456}];
                // $(".layui-table").find("tr.tableTitle").append('<th style="width: 22%">签名</th>');
                // $(".layui-table").find("tr.tableData").append('<td>阿斯蒂芬</td>');
                //比对的标准数据，所有和该列数据不一样的，就需要加样式了
                firstItem = data.data[0];

                $.each(data.data, function(){
                    var _self = this;
                    var title = _self.title;

                    //标题行
                    //如果是string类型，那么该列是最新更新的固定数据，
                    var titleHtml = "";
                    if (typeof title == "string") {
                        titleHtml += title;
                    } else {
                        var optionHtml = "";
                        title.forEach(function( val, index ) {
                            var fVersiondate = publicMethods.timeData(_self["fVersiondate"], "1");
                            var isSelected = "";
                            if (val == fVersiondate) {
                                isSelected = "selected";
                            }
                            optionHtml += '<option value="' + val + '" ' + isSelected + '>' + val + '</option>';
                        });
                        titleHtml += "<select lay-filter='versionTitle'>" + optionHtml + "</select>";
                    }
                    $(".layui-table").find("tr.tableTitle").append('<th style="min-width: 201px">' + titleHtml + '</th>');

                    //数据行
                    $(".layui-table").find("tr.tableData").each(function(){
                        var key = $(this).attr("dataFieldName");
                        var val = _self[key];
                        var tdStyle = "";
                        if(firstItem[key] != val){
                            tdStyle = "style='" + diffStyle + "'";
                        }
                        if (val == null) {
                            val = "";
                        }
                        val = convertFieldType(key, val);
                        var tdHtml = '<td ' + tdStyle + '>' + val + '</td>';
                        $(this).append(tdHtml);
                    });
                });

                //绑定标题行的下拉选项，返回的数据
                // 按照index索引，得到某行的固定列，同时清空样式，更新数据
                form.on('select(versionTitle)', function(){
                    var _self = $(this);
                    var index = 0;
                    for (var i = 0, len = $("th").length; i < len; i++) {
                        if ($(this).parents("th")[0] == $("th")[i]) {
                            index = i;
                            break;
                        }
                    }
                    var data = {};
                    data["fVersiondate"] = $(this).text();
                    data["id"] = id;
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdFalProblemreset/getHistoryByTime",
                        type : "POST",
                        data: data,
                        dataType: 'json',
                        success: function(result) {
                            //数据列
                            var data = result.data;
                            $(".layui-table").find("tr.tableData").each(function(){
                                var key = $(this).attr("dataFieldName");
                                var val = data[key];
                                var domObj = $(this).find("td")[index];
                                if(firstItem[key] != val){
                                    domObj.setAttribute("style", diffStyle);
                                }else{
                                    domObj.removeAttribute("style");
                                }
                                if (val == null) {
                                    val = "";
                                }
                                val = convertFieldType(key, val);
                                domObj.innerText = htmlDecodeByRegExp(val);
                            });
                        },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert("失败！" + XMLHttpRequest.status);
                        }
                    });
                });
            }
        });
        publicMethods.bottomFixd()
    });
</script>
<style>
    .title {
        border: solid 1px;
        border-right: 0px;
        display: block;
        float: left;
        font-family: "微软雅黑", "宋体", Arial, sans-serif;
    }
</style>
</body>
</html>